package com.xjrsoft.module.taskSchedule.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.core.tool.utils.StringPool;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.taskSchedule.dto.QueryTsLogPageListDto;
import com.xjrsoft.module.taskSchedule.entity.XjrTsLog;
import com.xjrsoft.module.taskSchedule.mapper.XjrTsLogMapper;
import com.xjrsoft.module.taskSchedule.service.IXjrTsLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.module.taskSchedule.vo.TaskLogVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 任务执行日志表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-11-10
 */
@Service
public class XjrTsLogServiceImpl extends ServiceImpl<XjrTsLogMapper, XjrTsLog> implements IXjrTsLogService {

    @Override
    public PageOutput<TaskLogVo> getPageList(QueryTsLogPageListDto dto) {
        String keyword = dto.getKeyword();
        if (StringUtil.isNotBlank(keyword)) {
            keyword = StringPool.PERCENT + keyword + StringPool.PERCENT;
        }
        IPage<Object> page = ConventPage.getPage(dto);
        List<TaskLogVo> logVoList = baseMapper.getPageList(dto.getStartTime(), dto.getEndTime(), keyword, dto.getExecuteResult(), page);
        return ConventPage.getPageOutput(page.getTotal(), logVoList);
    }
}
